﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8"/>
    <title>驰骋工作流引擎</title>
      <link href="../Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
		<link href="../Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
		<link href="../Style/skin/css/style.css" rel="stylesheet" type="text/css" />
		<link href="../Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
		<link href="../Style/skin/plugins/iCheck/custom.css" rel="stylesheet">
	<link href="../Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
    
    
</head>
<body topmargin="0" leftmargin="0" onkeypress="NoSubmit(event);">
	<div class="wrapper wrapper-content animated fadeInRight">
	
    <form  role="form"  onkeypress="NoSubmit(event);">
    	<div class="row">
    		 <div class="col-sm-12 form-inline pull-right"> 
    		 	<div class="form-group">
                      <label>关键字</label>
                      <input name="TB_KWds"  type="text" id="TB_KeyWords" class="form-control"  />
                 </div>
          
                  <div class="checkbox m-l m-r-xs">
                                <label class="i-checks">
                                    <input id="CHK_Myself" type="checkbox" name="CHK_Myself"  value="1"><i></i> 仅查询我审批的流程</label>
                    </div>
                 <div class="form-group">
                      <input type="button" value="按工作ID查" id="Btn_ByWorkID" name="ByWorkID" class="btn btn-white"  onclick="Btn_Click();"/>
                    <input type="button" value="按流程标题字段关键字查" id="Btn_ByTitle" name="ByTitle" class="btn btn-white"  onclick="Btn_Click();"/>
                 </div>
    		 </div>
    	</div>


        <div id="result">
        </div>

    </form>
   
       </div>
    <script src="../Scripts/jquery/jquery.min.js" type="text/javascript"></script>
    <script src="../Scripts/config.js" type="text/javascript"></script>
    <script src="../Scripts/QueryString.js" type="text/javascript"></script>
    <script src="../Comm/Gener.js" type="text/javascript"></script>
    
	 <script src="../Style/skin/plugins/iCheck/icheck.min.js"></script>
    <script>
        $(document).ready(function () {
            $('.i-checks').iCheck({
                checkboxClass: 'icheckbox_square-green',
                radioClass: 'iradio_square-green',
            });
        });
    </script>
    <script type="text/javascript">
        function OpenIt(workid, fk_node, fk_flow) {
            var url = '../WFRpt.htm?WorkID=' + workid + '&FK_Flow=' + fk_flow + '&FK_Node=' + fk_node;
            var newWindow = window.open(url, 'card', 'width=700,top=50,left=50,height=500,scrollbars=yes,resizable=yes,toolbar=false,location=false');
            newWindow.focus();
            return;
        }
    </script>
 
    <script type="text/javascript">
        function RSize() {

            if (document.body.scrollWidth > (window.screen.availWidth - 100)) {
                window.dialogWidth = (window.screen.availWidth - 100).toString() + "px"
            } else {
                window.dialogWidth = (document.body.scrollWidth + 50).toString() + "px"
            }

            if (document.body.scrollHeight > (window.screen.availHeight - 70)) {
                window.dialogHeight = (window.screen.availHeight - 50).toString() + "px"
            } else {
                window.dialogHeight = (document.body.scrollHeight + 115).toString() + "px"
            }
            window.dialogLeft = ((window.screen.availWidth - document.body.clientWidth) / 2).toString() + "px"
            window.dialogTop = ((window.screen.availHeight - document.body.clientHeight) / 2).toString() + "px"
        }

        function NoSubmit(ev) {
            if (window.event.srcElement.tagName == "TEXTAREA")
                return true;

            if (ev.keyCode == 13) {
                window.event.keyCode = 9;
                ev.keyCode = 9;
                return true;
            }
            return true;
        }

        function Btn_Click() {

            var key = $("#TB_KWds").val();
            if (key == null || key == undefined || key == "") {
                alert("请输入关键字...");
                return;
            }

            var handler = new HttpHandler("BP.WF.HttpHandler.WF_RptSearch");
            handler.AddPara("TB_KWds", key);
            var data = handler.DoMethodReturnString("KeySearch_Query");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            //转化成json.
            data = JSON.parse(data);
            if (data.length <= 0) {
                document.getElementById("result").innerHTML = "<h3>&nbsp;&nbsp;竟然没有查出任何东西，真不思议。</h3>";
                return;
            }

            var tableHtml = "<table class='Table'>",
                            statusArr = ["未完成", "已完成", "其他"],
                            tr = "";

            tableHtml += "<tr>";
            tableHtml += "<th>Idx</th>";
            tableHtml += "<th>流程</th>";
            tableHtml += "<th>停留节点</th>";
            tableHtml += "<th>处理人</th>";
            tableHtml += "<th>标题</th>";
            // tableHtml += "<th>轨迹图</th>";
            tableHtml += "<th>发起人</th>";
            tableHtml += "<th>发起日期</th>";
            tableHtml += "<th>状态</th>";
            tableHtml += "<th>参与人</th>";
            tableHtml += "</tr>";


            data.forEach(function (item, index) {
                tr = "";
                tr += "<td class=Idx >" + (index + 1) + "</td>";
                tr += "<td>" + item.FlowName + "</td>";
                tr += "<td>" + item.NodeName + "</td>";
                tr += "<td>" + item.TodoEmps + "</td>";
                tr += "<td><a href=\"javascript:OpenIt('" + item.WorkID + "','" + item.FK_Node + "','" + item.FK_Flow + "');\" >" + item.Title + "</a></td>";
                //  tr += "<td><a href=\"javascript:OpenIt('" + item.FK_Flow + "','" + item.FK_Node + "','" + item.WorkID + "');\" >轨迹</a></td>";
                tr += "<td>" + item.StarterName + "</td>";
                tr += "<td>" + item.RDT + "</td>";
                tr += "<td>" + statusArr[item.WFSta] + "</td>";
                tr += "\n<td class='BigDoc' valign=top>" + item.Emps + "</td>";
                tr += "</tr>";
                tableHtml += tr;
            });
            tableHtml += "</table>";
            document.getElementById("result").innerHTML = tableHtml;

        }


        /* 打开表单. */
        function OpenFrm(workid, nodeID, flowNo) {

            //执行催办.
            $.ajax({
                type: 'post',
                async: true,
                url: Handler + "?DoType=KeySearch_OpenFrm&FK_Node=" + nodeID + "&FK_Flow=" + flowNo + "&WorkID=" + workid + "&m=" + Math.random(),
                dataType: 'html',
                success: function (data) {
                    if (data.indexOf('err@') == 0) {
                        alert(data);
                        return;
                    }

                    if (data.indexOf('url@') == 0) {
                        data = data.replace('url@', '.');

                        window.open(data);
                        return;
                    }
                    alert(data);
                }
            });
        }
    </script>
</body>
</html>
